]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
StClipboard: add st_clipboard_get_mimetypes
authorAndy Holmes <andrew.g.r.holmes@gmail.com>
Thu, 21 May 2020 19:24:14 +0000 (12:24 -0700)
committerFlorian Müllner <florian.muellner@gmail.com>
Thu, 21 May 2020 22:24:59 +0000 (22:24 +0000)
Since the `MetaSelection` of the global `StClipboard` is private (and
should be), there is no reasonable way for extensions or external code
to query the supported mime-types.

Add `st_clipboard_get_mimetypes()` so this can be queried without
poking around in private code.

closes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2819

src/st/st-clipboard.c
src/st/st-clipboard.h

index 1dcd1e75f381c1a13113ebfce0d31562c3c83a87..52ad4941cb9363940f83b0e44aec41d72bbf225e 100644 (file)
@@ -146,6 +146,29 @@ transfer_cb (MetaSelection *selection,
   g_free (text);
 }
 
+/**
+ * st_clipboard_get_mimetypes:
+ * @clipboard: a #StClipboard
+ *
+ * Gets a list of the mimetypes supported by the default #StClipboard.
+ *
+ * Returns: (element-type utf8) (transfer full): the supported mimetypes
+ */
+GList *
+st_clipboard_get_mimetypes (StClipboard     *clipboard,
+                            StClipboardType  type)
+{
+  MetaSelectionType selection_type;
+
+  g_return_val_if_fail (ST_IS_CLIPBOARD (clipboard), NULL);
+  g_return_val_if_fail (meta_selection != NULL, NULL);
+
+  if (!convert_type (type, &selection_type))
+    return NULL;
+
+  return meta_selection_get_mimetypes (meta_selection, selection_type);
+}
+
 /**
  * st_clipboard_get_text:
  * @clipboard: A #StCliboard
index 60e3846010c4e80d684a913cd663112543d49fc6..22ef63f7fdee1ebc8571fcfa0af3ca5df0721654 100644 (file)
@@ -65,6 +65,9 @@ typedef void (*StClipboardCallbackFunc) (StClipboard *clipboard,
 
 StClipboard* st_clipboard_get_default (void);
 
+GList * st_clipboard_get_mimetypes (StClipboard             *clipboard,
+                                    StClipboardType          type);
+
 void st_clipboard_get_text (StClipboard             *clipboard,
                             StClipboardType          type,
                             StClipboardCallbackFunc  callback,